<template>
  <div class="app-container">
    <div ref="topForm">
      <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch"
        label-width="6.25rem">
        <el-form-item label="客户名" prop="clientName">
          <el-input v-model="queryParams.clientName" placeholder="请输入客户名" clearable @keyup.enter.native="handleQuery" />
        </el-form-item>
        <el-form-item label="计划名称" prop="planName">
          <el-input v-model="queryParams.planName" placeholder="请输入计划名称" clearable @keyup.enter.native="handleQuery" />
        </el-form-item>
        <el-form-item label="计划开始时间" prop="planStartDate">
          <el-date-picker clearable v-model="queryParams.planStartDate" type="date" value-format="yyyy-MM-dd"
            placeholder="请选择计划开始时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="计划结束时间" prop="planEndDate">
          <el-date-picker clearable v-model="queryParams.planEndDate" type="date" value-format="yyyy-MM-dd"
            placeholder="请选择计划结束时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="维保单位">
          <el-select v-model="queryParams.wbCompanyId" filterable clearable placeholder="请输入维保单位">
            <el-option v-for="item, index in maintainCompanyList" :key="index" :label="item.companyName"
              :value="item.id"></el-option>
          </el-select>
        </el-form-item>
        <!-- <el-form-item label="维保单位" prop="wbCompanyName">
          <el-input
            v-model="queryParams.wbCompanyName"
            placeholder="请输入维保单位"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item> -->
        <el-form-item label="技术负责人" prop="technololyPrincipalName">
          <el-input v-model="queryParams.technololyPrincipalName" placeholder="请输入技术负责人姓名" clearable
            @keyup.enter.native="handleQuery" />
        </el-form-item>

        <el-form-item label="操作者" prop="operaterName">
          <el-input v-model="queryParams.operaterName" placeholder="请输入操作者姓名" clearable
            @keyup.enter.native="handleQuery" />
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
          <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
        </el-form-item>
      </el-form>
      <el-row :gutter="10" class="mb8">
        <el-col :span="1.5">
          <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
            v-hasPermi="['wb:wbPlan:add']">新增</el-button>
        </el-col>
        <el-col :span="1.5">
          <el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete"
            v-hasPermi="['wb:wbPlan:remove']">删除</el-button>
        </el-col>
        <!-- <el-col :span="1.5">
          <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport"
            v-hasPermi="['wb:wbPlan:export']">导出</el-button>
        </el-col> -->
        <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
      </el-row>
    </div>

    <el-table v-loading="loading" :data="wbPlanList" :height="`calc(100vh - ${topHeight} - 200px)`" :key="isTable">
      <!-- <el-table-column type="selection" width="55" align="center" /> -->
      <!-- <el-table-column label="主键id" align="center" prop="id" />
      <el-table-column label="客户id" align="center" prop="clientId" /> -->
      <el-table-column label="序号" align="center" prop="id" width="55" />
      <el-table-column label="客户名" align="center" prop="clientName" />
      <el-table-column label="客户地址" align="center" prop="clientAddress" />
      <el-table-column label="计划类型" align="center" prop="planType">
        <template slot-scope="scope">
          <span>{{ fomatterLabelName('wbPlanType', scope.row.planType) }}</span>
        </template>
      </el-table-column>
      <el-table-column label="计划名称" align="center" prop="planName" />
      <el-table-column label="计划开始时间" align="center" prop="planStartDate" width="120">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.planStartDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="计划结束时间" align="center" prop="planEndDate" width="120">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.planEndDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <!-- <el-table-column label="实际开始时间" align="center" prop="execStartTime" width="120">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.execStartTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="实际结束时间" align="center" prop="execEndTime" width="120">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.execEndTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column> -->
      <!-- <el-table-column label="合同id" align="center" prop="contractId" />
      <el-table-column label="维保单位id" align="center" prop="wbCompanyId" /> -->
      <el-table-column label="维保单位" align="center" prop="wbCompanyName" />
      <!-- <el-table-column label="任务数" align="center" prop="contentNum" />
      <el-table-column label="待执行数" align="center" prop="executory" /> -->
      <!-- <el-table-column label="项目负责人" align="center" prop="projectPrincipalName" />
      <el-table-column label="技术负责人" align="center" prop="technololyPrincipalName" /> -->
      <!-- <el-table-column label="操作者id" align="center" prop="operaterId" /> -->
      <el-table-column label="负责人" align="center" prop="projectPrincipalId" />
      <el-table-column label="操作者" align="center" prop="operaterName" />
      <el-table-column label="执行状态" align="center" prop="execStatus">
        <template slot-scope="scope">
          {{ fomatterLabelName('wbStatus', scope.row.execStatus) }}
        </template>
      </el-table-column>
      <!-- <el-table-column label="审核状态" align="center" prop="auditStatus" width="120"/> -->
      <el-table-column label="完成时间" align="center" prop="finishTime" width="120">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.finishTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <!-- <el-table-column label="凭条" align="center" prop="entrySlip" width="100">
        <template slot-scope="scope">
          <image-preview :src="scope.row.entrySlip" :width="50" :height="50" />
        </template>
      </el-table-column>
      <el-table-column label="现场照片" align="center" prop="sitePhoto" width="100">
        <template slot-scope="scope">
          <image-preview :src="scope.row.sitePhoto" :width="50" :height="50" />
        </template>
      </el-table-column> -->
      <el-table-column label="描述" align="center" prop="remark" />
      <el-table-column label="操作" align="center" width="180" fixed="right" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <!-- <el-button size="mini" type="text" icon="el-icon-edit" @click="execute(scope.row)"
            v-hasPermi="['wb:wbPlan:edit']">执行</el-button> -->
          <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
            v-hasPermi="['wb:wbPlan:edit']">修改</el-button>
          <el-button size="mini" type="text" icon="el-icon-delete" v-if="scope.row.execStatus == 0"
            @click="handleDelete(scope.row)" v-hasPermi="['wb:wbPlan:remove']">删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
      @pagination="getList" />

    <!-- 添加或修改维保计划对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="56.25rem" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="7.5rem" class="dialog-form" :inline="true">
        <el-row>
          <el-col :span="22">
            <el-form-item label="计划名称" prop="planName" class="form-item-row">
              <el-input v-model="form.planName" placeholder="请输入计划名称" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="计划类型" prop="planType">
              <el-select v-model="form.planType" filterable clearable placeholder="请输入客户">
                <el-option v-for="item, index in Dictionary.wbPlanType" :key="index" :label="item.label"
                  :value="item.value"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="合同" prop="contractId">
              <el-select v-model="form.contractId" filterable clearable placeholder="请输入合同">
                <el-option v-for="item, index in contractList" :key="index" :label="item.name"
                  :value="item.id"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="客户" prop="clientId">
              <el-select v-model="form.clientId" filterable clearable placeholder="请输入客户">
                <el-option v-for="item, index in componentList" :key="index" :label="item.entName"
                  :value="item.id"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="维保单位" prop="wbCompanyId">
              <el-select v-model="form.wbCompanyId" filterable clearable placeholder="请输入维保单位" @change="companyChange">
                <el-option v-for="item, index in maintainCompanyList" :key="index" :label="item.companyName"
                  :value="item.id"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="计划开始时间" prop="planStartDate">
              <el-date-picker clearable v-model="form.planStartDate" type="date" value-format="yyyy-MM-dd"
                placeholder="请选择计划开始时间">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="计划结束时间" prop="planEndDate">
              <el-date-picker clearable v-model="form.planEndDate" type="date" value-format="yyyy-MM-dd"
                placeholder="请选择计划结束时间">
              </el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="客户名" prop="clientName">
              <el-input v-model="form.clientName" placeholder="请输入客户名" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="客户地址" prop="clientAddress">
              <el-input v-model="form.clientAddress" type="textarea" placeholder="请输入内容" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="类目" prop="classifyList" style="width: 100%;">
              <el-select class="classify" v-model="selectClassList" multiple placeholder="请选择类目" @focus="classSelection"
                ref="classSelect" @remove-tag="onRemoveTag">
                <el-option v-for="item in classifyList" :key="item.id" :label="item.classifyName" :value="item.id">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="负责人" prop="projectPrincipalId">
              <el-input v-model="form.projectPrincipalId" placeholder="请输入负责人" style="width: 13.75rem;" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="实施者" prop="operaterId">
              <el-select v-model="form.operaterId" placeholder="请选择实施者" @change="operaterChange">
                <el-option v-for="item in implementerList" :key="item.userId" :label="item.nickName"
                  :value="item.userId">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="完成时间" prop="finishTime">
              <el-date-picker clearable v-model="form.finishTime" type="date" value-format="yyyy-MM-dd"
                placeholder="请选择完成时间">
              </el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="消防师" prop="operaterId">
              <el-select v-model="form.fireFightingId" placeholder="请选择类目" @change="fireChange">
                <el-option v-for="item in firefighterList" :key="item.userId" :label="item.nickName"
                  :value="item.userId">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="工程师" prop="operaterId">
              <el-select v-model="form.engineerId" placeholder="请选择类目" @change="engineerChange">
                <el-option v-for="item in engineerList" :key="item.userId" :label="item.nickName" :value="item.userId">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>

        <!-- <el-form-item label="技术负责人" prop="technololyPrincipalId">
          <el-input v-model="form.technololyPrincipalId" placeholder="请输入技术负责人id" style="width: 13.75rem;" />
        </el-form-item> -->
        <!-- <el-form-item label="负责人项目" prop="projectPrincipalName">
          <el-input v-model="form.projectPrincipalName" placeholder="请输入负责人项目" />
        </el-form-item> -->
        <!-- <el-form-item label="技术负责人姓名" prop="technololyPrincipalName">
          <el-input v-model="form.technololyPrincipalName" placeholder="请输入技术负责人姓名" />
        </el-form-item> -->
        <!-- <el-form-item label="操作者姓名" prop="operaterName">
          <el-input v-model="form.operaterName" placeholder="请输入操作者姓名" />
        </el-form-item> -->
        <!-- <el-form-item label="维保单位" prop="wbCompanyName">
          <el-input v-model="form.wbCompanyName" placeholder="请输入维保单位" />
        </el-form-item> -->
        <!-- <el-form-item label="任务数" prop="contentNum">
          <el-input v-model="form.contentNum" placeholder="请输入任务数" />
        </el-form-item>
        <el-form-item label="待执行数" prop="executory">
          <el-input v-model="form.executory" placeholder="请输入待执行数" />
        </el-form-item> -->
        <!-- <el-form-item label="描述" prop="remark" class="form-item-row">
          <el-input v-model="form.remark" type="textarea" placeholder="请输入描述" />
        </el-form-item> -->
        <!-- <el-form-item label="凭条" prop="entrySlip" class="row">
          <image-upload v-model="form.entrySlip" />
        </el-form-item>
        <el-form-item label="现场照片" prop="sitePhoto" class="row">
          <image-upload v-model="form.sitePhoto" />
        </el-form-item> -->
        <!-- <el-form-item label="删除状态(1存在，2删除)" prop="delFlag">
          <el-input v-model="form.delFlag" placeholder="请输入删除状态(1存在，2删除)" />
        </el-form-item> -->

      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
    <el-dialog title="类目列表" :visible.sync="dialogTableVisible">
      <el-table ref="classTable" row-key="rid" v-loading="loading" :data="classifyList" @select="seleChange"
        @selection-change="handleSelectionChange">
        <el-table-column type="selection" width="55" prop="isCheckedStatus" :reserve-selection="true">
          <!-- <template slot-scope="{row}">
            <el-radio v-model="row.isCheckedStatus" label="1" @change="classCheck(row)"></el-radio>
          </template> -->
        </el-table-column>
        <el-table-column label="名称" align="center" prop="classifyName">
          <template slot-scope="scope">
            {{ scope.row.classifyName || scope.row.name }}
          </template>
        </el-table-column>
        <el-table-column label="状态" align="center" prop="status">
          <template slot-scope="{row}">
            {{ row.status == 0 ? '正常' : '停用' }}
          </template>
        </el-table-column>
        <!-- <el-table-column label="描述" align="center" prop="remark" /> -->
        <!-- <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
          <template slot-scope="scope">
            <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
              v-hasPermi="['wb:wbClassify:edit']">修改</el-button>
            <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
              v-hasPermi="['wb:wbClassify:remove']">删除</el-button>
          </template>
        </el-table-column> -->
      </el-table>
    </el-dialog>

  </div>
</template>

<script>
import { listWbPlan, newAddWbPlan, newUpdateWbPlan, newDelWbPlan, getWbDetail } from "@/api/wb/wbYearPlan";
import { listWbUserList } from '@/api/wb/userManage.js'
import { listWbClassifys } from "@/api/wb/wbClassify";
import { fomatterLabelName } from "@/utils/index.js"
import { listWbEntAuth } from "@/api/wb/wbEntAuth.js"
import { listWbMaintainCompany } from "@/api/wb/wbMaintainCompany.js"
import { listWbContract } from "@/api/wb/wbContract.js"
import Dictionary from "@/utils/dictionary";
export default {
  name: "WbPlan",
  data () {
    return {
      Dictionary,
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 维保计划表格数据
      wbPlanList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        clientId: null,
        clientName: null,
        clientAddress: null,
        planType: null,
        planName: null,
        planStartDate: null,
        planEndDate: null,
        execStartTime: null,
        execEndTime: null,
        contractId: null,
        wbCompanyId: null,
        wbCompanyName: null,
        contentNum: null,
        executory: null,
        projectPrincipalId: null,
        projectPrincipalName: null,
        technololyPrincipalId: null,
        technololyPrincipalName: null,
        operaterId: null,
        operaterName: null,
        execStatus: null,
        auditStatus: null,
        finishTime: null,
      },
      // 表单参数
      form: {},
      executeForm: {},
      // 表单校验
      rules: {
        classifyList: { required: true, message: '类目不能为空', trigger: 'blur' }
      },
      componentList: [],
      maintainCompanyList: [],
      contractList: [],
      topHeight: null,
      isTable: true,
      classifyList: [],
      firefighterList: [],
      engineerList: [],
      implementerList: [],
      dialogTableVisible: false,
      classifyIdList: [],
      selectClassList: [],
    };
  },
  created () {
    this.getList();
    // 查询所有业主公司
    this.getCompanyList();
    // 查询所有维保公司
    this.getWbList();
    // 查询所有合同
    this.getContractList();
    this.getWbClassify()
  },
  mounted () {
    this.$nextTick(() => {
      this.topHeight = this.$refs.topForm.offsetHeight + 'px'
    })
    // this.getEngineer()
    // this.getFirefighter()
    // this.listWbUserList()
    this.getUserInfo()
  },
  watch: {
    showSearch () {
      this.$nextTick(() => {
        this.topHeight = this.$refs.topForm.offsetHeight + 'px'
        this.isTable = !this.isTable
      })
    }
  },
  methods: {
    fomatterLabelName,
    getCompanyList () {
      listWbEntAuth({ state: 1 }).then(data => {
        this.componentList = data.rows;
      })
    },
    getWbList () {
      listWbMaintainCompany().then(data => {
        this.maintainCompanyList = data.rows
      })
    },
    getContractList () {
      listWbContract().then(data => {
        this.contractList = data.rows;
      })
    },
    /** 查询维保计划列表 */
    getList () {
      this.loading = true;
      listWbPlan(this.queryParams).then(response => {
        this.wbPlanList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    async getUserInfo () {
      this.firefighterList = await this.getUsers('一级消防师')
      this.engineerList = await this.getUsers('工程师')
      this.implementerList = await this.getUsers('维保人员')
    },
    // 取消按钮
    cancel () {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset () {
      this.form = {
        id: null,
        clientId: null,
        clientName: null,
        clientAddress: null,
        planType: null,
        planName: null,
        planStartDate: null,
        planEndDate: null,
        execStartTime: null,
        execEndTime: null,
        contractId: null,
        wbCompanyId: null,
        wbCompanyName: null,
        contentNum: null,
        executory: null,
        projectPrincipalId: null,
        projectPrincipalName: null,
        technololyPrincipalId: null,
        technololyPrincipalName: null,
        operaterId: null,
        operaterName: null,
        execStatus: null,
        auditStatus: null,
        finishTime: null,
        entrySlip: null,
        sitePhoto: null,
        delFlag: null,
        createTime: null,
        createBy: null,
        updateTime: null,
        updateBy: null,
        remark: null,
        classifyList: null,
        engineerId: null,
        engineerName: null,
        fireFightingId: null,
        fireFightingName: null,
      };
      this.selectClassList = []
      this.resetForm("form");
    },
    executeReset () {
      this.form = {
        id: null,
        remark: null
      };
      this.resetForm("execute-form");
    },
    /** 搜索按钮操作 */
    handleQuery () {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery () {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    /** 新增按钮操作 */
    handleAdd () {
      this.reset();
      this.open = true;
      this.title = "添加维保计划";
    },
    /** 修改按钮操作 */
    handleUpdate (row) {
      this.reset();
      const id = row.id || this.ids
      getWbDetail(id).then(response => {
        this.form = response.data;
        this.form.planType = Number(response.data.planType)
        response.data.planClassifyVos.forEach(item => {
          if (item.isCheckedStatus == 'true') {
            this.selectClassList.push(item.id)
          }
        })
        this.$set(this.form, 'classifyList', response.data.planClassifyVos)
        // this.form.classifyList = response.data.planClassifyVos
        this.open = true;
        this.title = "修改维保计划";
      });
    },
    /** 提交按钮 */
    submitForm () {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            newUpdateWbPlan(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            newAddWbPlan(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete (row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除维保计划？').then(() => {
        newDelWbPlan([ids]).then(res => {
          if (res.code == 200) {
            this.getList()
            this.$modal.msgSuccess("删除成功");
          }
        });
      })
    },
    /** 导出按钮操作 */
    handleExport () {
      this.download('wb/wbPlan/export', {
        ...this.queryParams
      }, `wbPlan_${new Date().getTime()}.xlsx`)
    },
    // 执行
    execute (row) {
      this.title = "执行维保计划";
    },
    // 获取类目列表
    getWbClassify () {
      listWbClassifys().then(res => {
        if (res.code == 200) {
          this.classifyList = [...res.rows]
          this.classifyList.map(item => {
            item.isCheckedStatus = false
          })
        }
      })
    },
    // 修改选中类目
    onRemoveTag (value) {
      console.log(value, 888);
    },
    // 获取消防师列表
    getFirefighter () {
      listWbUserList({ maintainCompanyRole: 2 }).then(res => {
        if (res.code !== 200) return
        this.firefighterList = [...res.rows]
      })
    },
    fireChange (value) {
      let firefighter = this.firefighterList.find(item => item.userId == value)
      if (!firefighter) return
      this.$set(this.form, 'fireFightingName', firefighter.nickName)
    },
    // 获取工程师列表
    getEngineer () {
      listWbUserList({ maintainCompanyRole: 1 }).then(res => {
        if (res.code !== 200) return
        this.engineerList = [...res.rows]
      })
    },
    engineerChange (value) {
      let engineer = this.engineerList.find(item => item.userId == value)
      if (!engineer) return
      this.$set(this.form, 'engineerName', engineer.nickName)
    },
    // 获取实施者列表
    listWbUserList () {
      listWbUserList({ maintainCompanyRole: 3 }).then(res => {
        if (res.code !== 200) return
        this.implementerList = [...res.rows]
      })
    },
    operaterChange (value) {
      let operater = this.implementerList.find(item => item.userId == value)
      if (!operater) return
      this.$set(this.form, 'operaterName', operater.nickName)
    },

    seleChange (seletion, row) {
      this.classifyList.forEach(item => {
        if (item.id == row.id) {
          item.isCheckedStatus = !item.isCheckedStatus
        }
      });
      this.selectClassList = []
      seletion.forEach(item => {
        this.selectClassList.push(item.id)
      })
      this.$set(this.form, 'classifyList', [...this.classifyList])
    },

    classSelection () {
      this.dialogTableVisible = true
      this.$refs.classSelect.blur()
    },

    classCheck (row) {
      this.classifyList.map(item => {
        if (row.id == item.id) {
          item.isCheckedStatus = !item.isCheckedStatus
        }
      })
    },

    handleSelectionChange (selection) {
      this.selectClassList = []
      if (selection.length) {
        this.classifyList.forEach(item => {
          item.isCheckedStatus = true
        });
      } else {
        this.classifyList.forEach(item => {
          item.isCheckedStatus = false
        });
      }
      selection.forEach(item => {
        this.selectClassList.push(item.id)
      })
      this.$set(this.form, 'classifyList', [...this.classifyList])
    },
    companyChange (e) {
      let company = this.maintainCompanyList.find(item => item.id == e)
      this.form.wbCompanyName = company.companyName
    },
  }
}
</script>
<style scoped>
.el-tag__close.el-icon-close {
  display: none !important;
}

::v-deep.classify .el-tag.el-tag--info .el-tag__close {
  display: none !important
}
</style>
